/*package view;

import java.awt.Dimension;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.JFrame;

import main.Log;
import model.entity.Avatar;
import model.entity.stats.StatSet;
import model.entity.stats.StatType;
import model.entity.stats.StatWithMax;
import model.item.EquippableItem;
import model.item.Inventory;
import model.item.TakeableItem;
import controller.InventoryController;

public class NaveenTests {

	public static void main(String[] args) {
		final GameWindow gw = new GameWindow("NaveenTests");
		gw.setSize(new Dimension(640, 480));
		gw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		StatSet stats = new StatSet();
		ArrayList<TakeableItem> inventoryList = new ArrayList<TakeableItem>();
		inventoryList.add(new EquippableItem("Sword!(1)"));
		inventoryList.add(new EquippableItem("Armor!(2)"));
		inventoryList.add(new EquippableItem("Shoes!(3)"));
		inventoryList.add(new EquippableItem("Cars!(4)"));
		inventoryList.add(new EquippableItem("Sword!(5)"));
		inventoryList.add(new EquippableItem("Armor!(6)"));
		inventoryList.add(new EquippableItem("Shoes!(7)"));
		inventoryList.add(new EquippableItem("Cars!(8)"));
		inventoryList.add(new EquippableItem("Sword!(9)"));
		inventoryList.add(new EquippableItem("Armor!(10)"));
		inventoryList.add(new EquippableItem("Shoes!(11)"));
		inventoryList.add(new EquippableItem("Cars!(12)"));
		inventoryList.add(new EquippableItem("Sword!(13)"));
		inventoryList.add(new EquippableItem("Armor!(14)"));
		inventoryList.add(new EquippableItem("Shoes!(15)"));
		inventoryList.add(new EquippableItem("Cars!(16)"));
		Inventory inventory = new Inventory(inventoryList);
		final Avatar a = new Avatar(stats, inventory);
		ListProvider inventoryListProvider = new InventoryListProvider(a);
		InventoryController inventoryController = new InventoryController(a, inventoryListProvider);
		ListOverlay inventoryListOverlay = new ListOverlay(gw.getSize(), inventoryListProvider, 3, 400, 200);
		stats.addStat(StatType.HP, new StatWithMax(225, StatType.HP, 225));
		
		gw.addOverlay(OverlayIds.STATS, new StatsOverlay(gw.getSize(), a));
		gw.addOverlay(OverlayIds.LIST, inventoryListOverlay);
		gw.addKeyListener(new KeyListener() {

			@Override
			public void keyPressed(KeyEvent arg0) {
				if (arg0.getKeyCode() == KeyEvent.VK_Q) {
					double hp = a.getStats().getStat(StatType.HP.toString()).getValue();
					//StatWithMax HP = a.getStat(StatType.HP);
					StatWithMax HP = (StatWithMax)(a.getStats().getStat(StatType.HP.toString()));
					//double max = a.getStatVal(StatType.MAXHP);
					double max = HP.getMaxValue();
					hp -= 1;
					a.getStats().addStat(StatType.HP, new StatWithMax(hp, StatType.HP, max));
					gw.update(gw.getGraphics());
				}
				if (arg0.getKeyChar()==27) {
					System.exit(0);
				}
			}

			@Override
			public void keyReleased(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void keyTyped(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		gw.addMouseListener(new MouseListener() {

			@Override
			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				Log.out(Log.VIEW, "Point: [" + e.getX() + ", " + e.getY() + "]");
			}

			@Override
			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		gw.addMouseListener(GameButtonRegistry.getInstance());
		gw.addComponentListener(new ComponentListener() {

			@Override
			public void componentHidden(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void componentMoved(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void componentResized(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				Log.out(Log.VIEW, "Game Window Resized: " + gw.getSize().toString());
			}

			@Override
			public void componentShown(ComponentEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
		});
		gw.setVisible(true);

	}

}
*/
/*
package view;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JFrame;

import main.Log;
import model.Executable;
import model.GameClock;
import model.entity.Avatar;
import model.entity.Occupation;
import model.entity.stats.Stat;
import model.entity.stats.StatSet;
import model.entity.stats.StatType;
import model.entity.stats.StatWithMax;
import model.interactionhandler.InteractionContainer;
import model.item.EquippableItem;
import model.item.Inventory;
import model.item.TakeableItem;
import model.map.Direction;
import model.map.FogOfWar;
import model.map.GameMap;
import model.map.HexLocationProjection;
import model.map.Location;
import model.map.MovementType;
import model.map.World;
import model.skill.Observation;
import controller.AvatarController;
import controller.CameraController;
import controller.InteractionController;
import controller.InventoryController;

public class NaveenTests {
	
	public static void main(String args[]) {
		testGrid();
//		testGameClock();
//		testEquipmentOverlay();
	}
	
	public static void testEquipmentOverlay() {
		EquipmentOverlay eo = new EquipmentOverlay( new Dimension(800,600), null, 
				new Point(200,200), null);
		
		GameWindow gw = new GameWindow("NaveenTests");
		gw.addOverlay( "testMapOverlay", eo );
		gw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		gw.setSize( 800, 600 );
		gw.addMouseListener( GameButtonRegistry.getInstance() );
		gw.setVisible(true);
	}
	
	public static void testGrid() {
		Avatar avatar = createDummyAvatar();
		avatar.setInventory(createInventory());
		World.getInstance().setPlayer(avatar);
		
		GameMap gm = new GameMap();
		World.getInstance().setCurrentMap(gm);
		gm.addEntity( avatar );
		FogOfWar fow = new FogOfWar( gm, avatar, new HexLocationProjection());
		
		MapOverlay mo = new MapOverlay(new Dimension(800,600), gm, new Location(13,13) );
		
		loadTestImages();//loads images into ModelToImage classes		
		
		GameWindow gw = new GameWindow("NaveenTests");
		gw.setSize( 800, 600 );
		gw.addOverlay( "testMapOverlay", mo );
		addFavoriteListeners(gw);
		initializeRefresh( gw );
		ObservationOverlay oo = new ObservationOverlay(new Dimension(800, 600), avatar );
		InteractionOverlay io = new InteractionOverlay( new Dimension(800,600), InteractionContainer.getInstance() );
		CameraController cc = new CameraController( mo, gw );
		AvatarController ac = new AvatarController( avatar, gw, mo,  InteractionContainer.getInstance());
		InteractionController ic2 = new InteractionController( io, gw, InteractionContainer.getInstance());

		//Create InventoryListProvider
		ListProvider inventoryListProvider = new InventoryListProvider(avatar.getInventory());
		InventoryController ic = new InventoryController(avatar, inventoryListProvider);
		ListOverlay lo = new ListOverlay(mo.getOuterDimension(), inventoryListProvider, 3, 400, 50 );
		
		gw.addOverlay(OverlayIds.STATS, new StatsOverlay(gw.getSize(), avatar, new Point(30, 30), 50));
		gw.addOverlay(OverlayIds.LIST, lo);
		gw.addOverlay( "testInteractionoverlay", io);
		gw.addOverlay(OverlayIds.OBSERVATION, oo);
		gw.addMouseListener(GameButtonRegistry.getInstance() );
		
		gw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		gw.setVisible(true);
		World.getInstance().getCurrentMap().getFogOfWar().update();
	}
	
	public static Avatar createDummyAvatar() {
		ArrayList<MovementType> mt = new ArrayList<MovementType>();
		mt.add( MovementType.GRASS );
		StatSet stats = new StatSet();
		stats.addStat(StatType.MOVEMENTSPEED, new Stat(10, StatType.MOVEMENTSPEED));
		stats.addStat(StatType.HP, new StatWithMax(225, StatType.HP, 225));
		stats.addStat(StatType.MP, new StatWithMax(225, StatType.MP, 225));
		stats.addStat(StatType.OBSERVATION, new Stat(0, StatType.OBSERVATION));
		stats.addStat(StatType.SIGHTRANGE, new Stat(5, StatType.SIGHTRANGE));
		Occupation occupation = new Occupation();
		Observation observation = new Observation();
		occupation.addNonActivateableSkill(observation);
		Avatar avatar = new Avatar("entity", Direction.S, new Location(11,13), stats, mt , null, null, occupation, false);
		return avatar;
	}
	
	public static void initializeRefresh( final GameWindow gw ) {
		GameClock.getInstance().scheduleAtFixedRate( 1, new Executable() {
			@Override
			public void execute() {
				gw.repaint();
			}
		} );
	}
	
	public static void loadTestImages() {
		ModelToImage.addImage( "Unpassable", "./Data/imgs/grayTile.png" );
		ModelToImage.addImage( "Grass", "./Data/imgs/greenTile.png" );
		ModelToImage.addImage( "obstacle", "./Data/imgs/obstacle.png" );
		ModelToImage.addImage( "areaEffect", "./Data/imgs/areaEffect.png" );
		ModelToImage.addImage( "decal", "./Data/imgs/decal.png" );
		ModelToImage.addImage( "item", "./Data/imgs/item.png" );
		//add entity
		Map<Direction, String> m0 = new HashMap<Direction, String>();
		m0.put(Direction.S, "./Data/imgs/avatar_s.png");
		m0.put(Direction.SE, "./Data/imgs/avatar_se.png");
		m0.put(Direction.SW, "./Data/imgs/avatar_sw.png");
		m0.put(Direction.N, "./Data/imgs/avatar_n.png");
		m0.put(Direction.NE, "./Data/imgs/avatar_ne.png");
		m0.put(Direction.NW, "./Data/imgs/avatar_nw.png");
		DirectionalModelToImage.addImage("entity", m0);
		//add vehicle
		Map<Direction, String> m1 = new HashMap<Direction, String>();
		m1.put(Direction.S, "./Data/imgs/vehicle.png");
		DirectionalModelToImage.addImage("vehicle", m1);
		//add projectile
		ModelToImage.addImage( "projectile", "./Data/imgs/projectile.png" );
		
		//add semitransparent tile
		ModelToImage.addImage( "semitransparentTile", "./Data/imgs/semitransparentHexagon.png" );
	}

	public static void testGameClock() {
		final GameClock c = GameClock.getInstance();
		Log.out( Log.VIEW, "Before first executable.");
		final Executable e = new Executable() {
			@Override
			public void execute() {
				Log.out( Log.VIEW, "In first executable.");
			}
		};
		Executable e2 = new Executable() {
			@Override
			public void execute() {
				Log.out( Log.VIEW, "In second executable: remove first executable.");
				c.remove( e );
			}
		};
		c.scheduleAtFixedRate(80, e);
		c.schedule(410, e2);
	}
	public static Inventory createInventory() {
		ArrayList<TakeableItem> inventoryList = new ArrayList<TakeableItem>();
		inventoryList.add(new EquippableItem("Sword!(1)"));
		inventoryList.add(new EquippableItem("Armor!(2)"));
		inventoryList.add(new EquippableItem("Shoes!(3)"));
		inventoryList.add(new EquippableItem("Cars!(4)"));
		inventoryList.add(new EquippableItem("Sword!(5)"));
		inventoryList.add(new EquippableItem("Armor!(6)"));
		inventoryList.add(new EquippableItem("Shoes!(7)"));
		inventoryList.add(new EquippableItem("Cars!(8)"));
		inventoryList.add(new EquippableItem("Sword!(9)"));
		inventoryList.add(new EquippableItem("Armor!(10)"));
		inventoryList.add(new EquippableItem("Shoes!(11)"));
		inventoryList.add(new EquippableItem("Cars!(12)"));
		inventoryList.add(new EquippableItem("Sword!(13)"));
		inventoryList.add(new EquippableItem("Armor!(14)"));
		inventoryList.add(new EquippableItem("Shoes!(15)"));
		inventoryList.add(new EquippableItem("Cars!(16)"));
		Inventory inventory = new Inventory(inventoryList);
		return inventory;
	}
	public static void addFavoriteListeners(final GameWindow gw) {
		gw.addKeyListener(new KeyListener() {

			@Override
			public void keyPressed(KeyEvent arg0) {
				if (arg0.getKeyChar()== KeyEvent.VK_SPACE) {
					System.exit(0);
				}
			}

			@Override
			public void keyReleased(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void keyTyped(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});

	}
}
*/
package view;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JFrame;

import main.Log;
import model.Executable;
import model.GameClock;
import model.entity.Avatar;
import model.entity.Occupation;
import model.entity.stats.Stat;
import model.entity.stats.StatSet;
import model.entity.stats.StatType;
import model.entity.stats.StatWithMax;
import model.handler.DeathHandler;
import model.interactionhandler.InteractionContainer;
import model.item.Inventory;
import model.map.Direction;
import model.map.FogOfWar;
import model.map.GameMap;
import model.map.HexLocationProjection;
import model.map.Location;
import model.map.MovementType;
import model.map.World;
import model.skill.Observation;
import controller.AvatarController;
import controller.CameraController;
import controller.InteractionController;

public class NaveenTests {
	
	public static void main(String args[]) {
		testGrid();
//		testGameClock();
//		testEquipmentOverlay();
	}
	
	public static void testEquipmentOverlay() {
		EquipmentOverlay eo = new EquipmentOverlay( new Dimension(800,600), null, 
				new Point(200,200), null);
		
		GameWindow gw = new GameWindow("AlejandroTests");
		gw.addOverlay( "testMapOverlay", eo );
		gw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		gw.setSize( 800, 600 );
		gw.addMouseListener( GameButtonRegistry.getInstance() );
		gw.setVisible(true);
	}
	
	public static void testGrid() {
		Avatar avatar = createDummyAvatar();
		World.getInstance().setPlayer(avatar);
		
		GameMap gm = new GameMap();
		World.getInstance().addMap( gm );
		World.getInstance().setCurrentMap( gm );
		gm.addEntity( avatar );
		FogOfWar fow = new FogOfWar( gm, avatar, new HexLocationProjection());
		
		World.getInstance().setPlayer( avatar );
		
		MapOverlay mo = new MapOverlay( new Dimension(800,600), gm, new Location(13,13) );
		InteractionOverlay io = new InteractionOverlay( new Dimension(800,600), InteractionContainer.getInstance() );
		loadTestImages();//loads images into ModelToImage classes
		ObservationOverlay oo = new ObservationOverlay(new Dimension(800, 600), avatar);
		
		GameWindow gw = new GameWindow("AlejandroTests");
		addFavoriteListeners(gw);
		gw.setSize( 800, 600 );
		gw.addOverlay( "testMapOverlay", mo );
		gw.addOverlay(OverlayIds.OBSERVATION, oo);
		gw.addOverlay( "testInteractionoverlay", io);
		
		StatsOverlay sl = new StatsOverlay(gw.getSize(), avatar, new Point(20, 20), 30);
        gw.addOverlay(OverlayIds.STATS, sl);
        gw.addOverlay(OverlayIds.OBSERVATION, oo);
		
		initializeRefresh( gw );
		
		CameraController cc = new CameraController( mo, gw );
		AvatarController ac = new AvatarController( avatar, gw, mo, InteractionContainer.getInstance());
		InteractionController ic = new InteractionController( io, gw, InteractionContainer.getInstance());
		
		gw.addMouseListener( GameButtonRegistry.getInstance() );
		
		gw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		gw.setVisible(true);
		
		World.getInstance().getCurrentMap().getFogOfWar().update();
		
		DeathHandler.getInstance().start();
	}
	
	public static Avatar createDummyAvatar() {
		ArrayList<MovementType> mt = new ArrayList<MovementType>();
		mt.add( MovementType.GRASS );
		StatSet stats = new StatSet();
		stats.addStat(StatType.MOVEMENTSPEED, new Stat(1, StatType.MOVEMENTSPEED));
		stats.addStat(StatType.SIGHTRANGE, new Stat(5, StatType.SIGHTRANGE));
		stats.addStat(StatType.HP, new StatWithMax(2000, StatType.HP, 2000));
        stats.addStat(StatType.MP, new StatWithMax(2000, StatType.MP, 2000));
        stats.addStat(StatType.PICKPOCKET, new Stat(90, StatType.PICKPOCKET));
        stats.addStat(StatType.OBSERVATION, new Stat(100, StatType.OBSERVATION));
        Occupation occupation = new Occupation();
        Observation observation = new Observation();
        occupation.addNonActivateableSkill(observation);
		Avatar avatar = new Avatar("entity", Direction.S, new Location(11,13), stats, mt , new Inventory(), null, occupation, false);
		return avatar;
	}
	
	public static void initializeRefresh( final GameWindow gw ) {
		GameClock.getInstance().scheduleAtFixedRate( 1, new Executable() {
			@Override
			public void execute() {
				gw.repaint();
			}
		} );
	}
	
	public static void loadTestImages() {
		ModelToImage.addImage( "Unpassable", "./Data/imgs/grayTile.png" );
		ModelToImage.addImage( "Grass", "./Data/imgs/greenTile.png" );
		ModelToImage.addImage( "obstacle", "./Data/imgs/obstacle.png" );
		ModelToImage.addImage( "areaEffect", "./Data/imgs/areaEffect.png" );
		ModelToImage.addImage( "decal", "./Data/imgs/decal.png" );
		ModelToImage.addImage( "item", "./Data/imgs/item.png" );
		//add entity
		Map<Direction, String> m0 = new HashMap<Direction, String>();
		m0.put(Direction.S, "./Data/imgs/avatar_s.png");
		m0.put(Direction.SE, "./Data/imgs/avatar_se.png");
		m0.put(Direction.SW, "./Data/imgs/avatar_sw.png");
		m0.put(Direction.N, "./Data/imgs/avatar_n.png");
		m0.put(Direction.NE, "./Data/imgs/avatar_ne.png");
		m0.put(Direction.NW, "./Data/imgs/avatar_nw.png");
		DirectionalModelToImage.addImage("entity", m0);
		//add vehicle
		Map<Direction, String> m1 = new HashMap<Direction, String>();
		m1.put(Direction.S, "./Data/imgs/vehicle.png");
		DirectionalModelToImage.addImage("vehicle", m1);
		//add projectile
		ModelToImage.addImage( "projectile", "./Data/imgs/projectile.png" );
		
		//add semitransparent tile
		ModelToImage.addImage( "semitransparentTile", "./Data/imgs/semitransparentHexagon.png" );
	}

	public static void testGameClock() {
		final GameClock c = GameClock.getInstance();
		Log.out( Log.VIEW, "Before first executable.");
		final Executable e = new Executable() {
			@Override
			public void execute() {
				Log.out( Log.VIEW, "In first executable.");
			}
		};
		Executable e2 = new Executable() {
			@Override
			public void execute() {
				Log.out( Log.VIEW, "In second executable: remove first executable.");
				c.remove( e );
			}
		};
		c.scheduleAtFixedRate(80, e);
		c.schedule(410, e2);
	}
	public static void addFavoriteListeners(final GameWindow gw) {
		gw.addKeyListener(new KeyListener() {

			@Override
			public void keyPressed(KeyEvent arg0) {
				if (arg0.getKeyChar()== KeyEvent.VK_SPACE) {
					System.exit(0);
				}
			}

			@Override
			public void keyReleased(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void keyTyped(KeyEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});
		gw.addMouseListener(new MouseListener() {

			@Override
			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				Log.out(Log.VIEW, "Point: [" + e.getX() + ", " + e.getY() + "]");
			}

			@Override
			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}
}
